#ifndef SERVER_H
#define SERVER_H
#include <string>
#include <boost/asio.hpp>
#include "callback.h"
#include "tcp_connection.h"
#include "common/thread_pool.h"

using namespace boost::asio;
using namespace boost::asio::ip;

class TcpServer
{
public:
	TcpServer(const std::string& port, const std::string addr="0.0.0.0");

	void start(int thread_num = 1);

private:
	void startAccept();
	
	void onConnection(const boost::system::error_code& err);	

	void handlStop(){};

private:
	io_service			io_server_;
	tcp::acceptor		acceptor_;
	signal_set			signal_set_;
	TcpConnectionPtr	new_connection_;
};

#endif
